<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thêm loại laptop</title>

<link href="../style/cssqt.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function kiemtrathemloai()
	{
		var s=document.formthem;
		
		if(s.maloai.value=='')
		{
			document.getElementById("maloai_error").style.display = "block";
			document.getElementById("maloai_error").innerHTML="Bạn chưa nhập mã loại laptop!";
			s.maloai.focus();
			return false;	
		}
		else
			document.getElementById("maloai_error").style.display = "none";
			
		if(s.tenloai.value=='')
		{
			document.getElementById("tenloai_error").style.display = "block";
			document.getElementById("tenloai_error").innerHTML="Bạn chưa nhập tên loại laptop!";
			s.tenloai.focus();
			return false;	
		}
		else
			document.getElementById("tenloai_error").style.display = "none";
				
		
			return true;
}
</script>

</head>

<body>
<?php
include("../config/config.php");
$maloai = $_POST["maloai"];
$tenloai = $_POST["tenloai"];
if(isset($_POST["them"]))
{

	$lenhthem = "insert into loailaptop values('$maloai','$tenloai')";
	$kqthem = mysql_query($lenhthem);
	if($kqthem)
	{
		?>
		<script>
		alert('thêm thành công!');
		location.href='indexqt.php?act=loai';
		</script>
	   <?php
	  
		
	}
}
?>
<form id="formthem" name="formthem" method="post" action="" onsubmit="return kiemtrathemloai()">
  <table width="1110" border="1" align="center" cellpadding="0" cellspacing="0" class="table_khachhang">
    <tr>
      <td height="30" colspan="2" align="center" class="title_table">Thêm Loại Laptop</td>
      
    </tr>
    <tr>
      <td width="249" height="30">Mã loại</td>
      <td width="645" height="30"><label for="maloai"></label>
      <input name="maloai" type="text" class="onhapdangkyvuaqt" id="maloai" value="<?php echo $_POST["maloai"] ?>" placeholder="Mã loại laptop" /><font color="#FF0000">(*)
      <span class="hide error" id="maloai_error"> </span> </font></td>
    </tr>
    <tr>
      <td height="30">Tên loại</td>
      <td height="30"><label for="tenloai"></label>
      <input name="tenloai" type="text" class="onhapdangkyvuaqt" id="tenloai" value="<?php echo $_POST["tenloai"] ?>" placeholder="Tên loại laptop" /><font color="#FF0000">(*)
      <span class="hide error" id="tenloai_error"> </span> </font></td>
    </tr>
    <tr>
      <td height="30" colspan="2" align="center"><input name="them" type="submit" class="nutbutton" id="them" value="Thêm" /></td>
    </tr>
  </table>
</form>
</body>
</html>